package com.lanbu.system.service.impl;

import com.lanbu.system.domain.mongo.MongoTeamMembers;
import com.lanbu.system.domain.mongo.MongoTeamMembersGroups;
import com.lanbu.system.mapper.MongoTeamMembersGroupsRepository;
import com.lanbu.system.mapper.MongoTeamMembersRepository;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class MongoTeamMembersGroupsService {

    private final MongoTeamMembersGroupsRepository teamMembersGroupsRepository;

    @Autowired
    public MongoTeamMembersGroupsService(MongoTeamMembersGroupsRepository teamMembersRepository) {
        this.teamMembersGroupsRepository = teamMembersRepository;
    }


    public List<MongoTeamMembersGroups> findAll() {
        return teamMembersGroupsRepository.findAll();
    }

    public List<MongoTeamMembersGroups> findByTeamId(ObjectId teamId) {
        return teamMembersGroupsRepository.findByTeamId(teamId);
    }

    public Optional<MongoTeamMembersGroups> findById(ObjectId id) {
        return teamMembersGroupsRepository.findById(id);
    }


    public MongoTeamMembersGroups save(MongoTeamMembersGroups teamMember) {
        return teamMembersGroupsRepository.save(teamMember);
    }


    public void deleteById(ObjectId id) {
        teamMembersGroupsRepository.deleteById(id);
    }

    public MongoTeamMembersGroups findByUserId(ObjectId userId){
        return teamMembersGroupsRepository.findByUserId(userId);
    }
}
